import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      // TODO 到底跳转到哪个路由呢
      redirect: "/login",
    },
    {
      path: "/login",
      name: "login",
      component: () => import("../views/LoginView.vue"),
    },
    // homeView
    {
      path: "/home",
      name: "home",
      component: () => import("../views/HomeView.vue"),
    },
    {
      path: "/chun",
      name: "chun",
      component: () => import("../views/ChunView.vue"),
    },
    {
      path: "/web",
      name: "web",
      component: () => import("../views/WebView.vue"),
    },
    {
      path: "/sys",
      name: "sys",
      component: () => import("../views/SystemView.vue"),
      redirect: "/user",
      children: [
        {
          path: "/user",
          name: "user",
          component: () => import("../components/system/User.vue"),
        }, {
          path: "/mailList",
          name: "mailList",
          component: () => import("../components/system/Mail.vue"),
        }, {
          path: "/role",
          name: "role",
          component: () => import("../components/system/Role.vue"),
        },
        {
          path: "/department",
          name: "department",
          component: () => import("../components/system/DepartManage.vue"),
        },


        {
          path: "/warning",
          name: "warning",
          component: () => import("../components/system/Warn.vue"),
        },
        {
          path: "/tidecsv",
          name: "tidecsv",
          component: () => import("../components/system/TideCsv.vue"),
        }, {
          path: "/warningdoc",
          name: "warningdoc",
          component: () => import("../components/system/WarningDoc.vue"),
        },
        {
          path: "/dataSource",
          name: "dataSource",
          component: () => import("../components/system/DataSource.vue"),
        },

      ],
    },
  ],
});

// router.beforeEach((to, from, next) => {
//   const token = sessionStorage.getItem("token");


//   if (to.path === "/login") {
//     next();
//   } else {
//     if (token) {
//       next();
//     } else {
//       next("/login");
//     }
//   }
// });

export default router;
